Repository navigation
fix(novelty): estimate-only splits dollars by role and names the least sure one - #1218
Conversation
…ure (intel#631) `novelty analyze --estimate-only` printed one `expected_usd` with no hint of which role's token profile it leans on, and a run billed above it (the issue's 777 calls at $6.00 against `expected_usd: 5.93`) gave no pointer to the extractor. The payload now carries `usd_by_role` (extractor, answerer and judge list-price dollars, panel judges after the first under `judge`) and `least_sure_role` (a role and a reason), both null when `expected_usd` is null. A tier with no extractor profile of its own (`study`, or no tier) names the extractor, which borrows the standard profile; `triage` and `standard` name the role with the largest dollars. There is no per-role error data behind that rule. stderr prints one line with the role and its share before the existing estimate notes. `tiers.estimate_usd` and the split share one pricing loop (`tiers.usd_by_role`); `expected_usd` and every existing note are unchanged. Refitting the token profile per tier needs measured paid runs and is left to a follow-up. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 8 selected item(s). CI at Review details
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1218 +/- ##
==========================================
- Coverage 96.07% 96.06% -0.02%
==========================================
Files 496 496
Lines 65209 65314 +105
Branches 11317 11336 +19
==========================================
+ Hits 62652 62746 +94
- Misses 1583 1589 +6
- Partials 974 979 +5
🚀 New features to boost your workflow:
|
…e guards Settles the codecov concern on cost.py. role_usd runs only after estimate_usd has resolved the role models and priced every role and panel judge, so its ValueError guard around role_models and its None return for a panel judge's price could not be reached; they are gone. The remaining None return for an unpriced role is now covered by a test that calls role_usd with an unpriced model. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
napetrov
left a comment
There was a problem hiding this comment.
Change class: CONTRACT (head b4c4e37)
- Contract: changed (count signal only, no file:line)
- Responsibility: none
- Dependency: none
- Review depth: check the changed surface: callers, docs, tests pin new behaviour
- Coverage gaps: none
The per-role estimates include the extra panel judges and preserve an unknown total when pricing is unavailable. The documentation explains how the least-sure role is selected. The two focused novelty estimate suites passed locally (52 tests), and GitHub CI is green.
Summary
On
main,novelty analyze --estimate-only(and--dry-run) prints oneexpected_usdand nothing says which role's token profile it leans on. The issue's run billed $6.00 for 777 calls where the estimate saidexpected_usd: 5.93for 815 calls, with the extractor suspected (4 extractor calls of a triage run billed 16.4k output tokens, $0.38 of $0.95). That run was not repeated here; it rests on the issue's billed figures. Onmainthe payload has no per-role dollars: the new tests fail on a missingusd_by_rolekey.The issue offers two fixes. This PR takes the second, reporting which role the estimate is least sure of next to
expected_usd. Refitting the token profile per role against measured runs per tier needs new paid runs per tier and role, which an offline build cannot make; it is left to #1217.Closes #631
Changes
dokimi/novelty/tiers.py:usd_by_roleis the one per-role pricing loop;estimate_usdkeeps its signature and sums it, soexpected_usdis unchanged.dokimi/novelty/cost.py:role_usdprices each role's calls (panel judges after the first count underjudge),least_sure_roleapplies the rule below,add_role_usdputsusd_by_roleandleast_sure_rolein the estimate payload (bothnullwhenexpected_usdisnull), andleast_sure_lineformats the stderr line.dokimi/commands/novelty_budget.py:run_estimateadds the two keys next toexpected_usd;print_estimate_onlyprintsLeast sure of: <role> (<n>% of expected_usd): <reason>after the JSON and before the existing "Estimate only, nothing was measured" note. TheExpected ~$X for this run at list pricesline is untouched.study, or no tier) namesextractor, since it borrows the standard profile;triageandstandardname the role with the largest share ofexpected_usd, the first of extractor, answerer, judge on a tie.docs/skill-novelty.mdanddocs/skill-novelty-walkthrough.mdname the two fields and the rule.tests/test_novelty_estimate_roles.py;tests/test_novelty_settings_parity.pyaddsusd_by_roleandleast_sure_roleto its bill keys (novelty analyze --estimate-only prices below the measured bill #631) and strips the new stderr line from the run, asserting it is there exactly whenleast_sure_roleis not null. The golden file is not recaptured.role_usdruns only afterestimate_usdhas resolved the role models and priced every role and panel judge, so itsValueErrorguard aroundrole_modelsand itsNonereturn for an unpriced panel judge were unreachable and are removed; itsNonereturn for an unpriced role is covered bytest_role_usd_is_none_for_an_unpriced_role.Risk
The payload gains two keys and stderr gains one line; every existing value, call count and note keeps its wording, and
expected_usdis computed by the same loop in the same order. A consumer that rejects unknown keys in the estimate JSON would notice.usd_by_rolevalues are each rounded to 6 places, so they sum toexpected_usdwithin rounding, not exactly.Open PRs on the same files: #1190 changes the
InputErrorimport inrun_estimatea few lines above this PR's hunk, and #1197 and #1176 edit other paragraphs of the two novelty docs; none touches the lines changed here. #1197 moves the novelty flags toPROVIDER/MODELspellings: whichever merges second may need the new test's--model foo-bar-9 --provider openaiwritten in the other form.Testing
On a Linux review host, at
b4c4e37d(onmain602de140):make ci-local: 38 passed, 0 failed, 15 skipped (docker external-catalog smoke, the pinned Claude Code install, the jobs that do not run on a PR, the CLI-surface package step, conda-forge, other-Python matrix legs, fuzz, semgrep). 28393 tests passed, 23 skipped. A first run hit the 60 s timeout intests/test_repo_typecheck_grader.py(untouched); alone it passed (108 passed), and the rerun was green.tests/test_novelty_estimate_roles.pyonmain's code: 10 failed, each on a missingusd_by_roleorleast_sure_rolekey; here they pass.maxtomin, panel judges dropped, the percent inverted, the answerer's dollars doubled, an unpriced run giving zeros instead ofnull, the stderr line moved after the estimate note, a role dropped from the dict.test_role_usd_is_none_for_an_unpriced_role(11th test in the file): withrole_usdreturning an empty split instead ofNonefor an unpriced role, it fails. The coverage report onnovelty/cost.pyno longer lists lines 131-142.fastcontextwith--tier triage --dry-run:usd_by_roleis{"extractor": 0.076752, "answerer": 0.1846, "judge": 0.0915}forexpected_usd: 0.352852, and stderr saysLeast sure of: answerer (52% of expected_usd).Open questions
least_sure_rolerule was chosen for this PR; no per-role error data stands behind it. Fortriageandstandardit names the role with the most dollars, which on a small skill is the answerer, not the extractor the issue suspects. Once the profile is refit (novelty analyze --estimate-only: refit the per-role token profile against measured runs per tier #1217), should the rule use the measured per-role error instead?Revert
A plain revert restores the payload and stderr of
main. Nothing is stored.Checklist
pytestpassesruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to [no newraiseor exit; the new tests name novelty analyze --estimate-only prices below the measured bill #631 in their module docstring].github/.licenserc.yaml)